package com.ias.agdis_r.adapter;

import java.util.LinkedList;
import java.util.List;

import com.ias.agdis_r.R;
import com.ias.agdis_r.bean.fight.FlightChanged;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class FlightStateHistoryAdapter extends BaseAdapter {

	private List<FlightChanged> data = new LinkedList<FlightChanged>();
	private Context context;

	public FlightStateHistoryAdapter(Context context, List<FlightChanged> data) {
		this.data = data;
		this.context = context;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(R.layout.item_flight_state_change, parent, false);
		}
		TextView text1 = (TextView) convertView.findViewById(android.R.id.text1);
		TextView text2 = (TextView) convertView.findViewById(android.R.id.text2);
		text1.setText(data.get(position).getTime());
		text2.setText(data.get(position).getMsg());
		return convertView;
	}

	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

}
